/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "sle_hal_test_entry.h"
#include "sle_loader_hal.h"
#include "sle_ssap_client_hal.h"
#include "sle_hal_errcode.h"

static SleSsapcHalCallbacks *g_sleSsapcHalUtCbs;
static uint16_t g_connectId = 0;
static uint8_t g_clientId = 0;
static SleUuid g_appUuid = {
    .len = 16,
};

void OnSleHalUtFindStructureCallback(uint8_t clientId, uint16_t connectId, const ClientFindServiceRes *service, SleHalErrorCode status)
{
    SLE_UT_LOG("[SleSsapcHalUt][PASSED]OnSleHalUtFindStructureCallback");
    return;
}

static uint16_t g_propertyHandle;
void OnSleHalUtFindPropertyCallback(uint8_t clientId, uint16_t connectId, const ClientFindPropertyRes *property, SleHalErrorCode status)
{
    SLE_UT_LOG("[SleSsapcHalUt][PASSED]OnSleHalUtFindPropertyCallback");
    g_propertyHandle = property->handle;
    return;
}

void OnSleHalUtCompleteFindStructureCallback(uint8_t clientId, uint16_t connectId, const ClientFindStructureRes *structureResult, SleHalErrorCode status)
{
    SLE_UT_LOG("[SleSsapcHalUt][PASSED]OnSleHalUtCompleteFindStructureCallback");
    return;
}

void OnSleHalUtReceiveReadResponseCallback(uint8_t clientId, uint16_t connectId, const ClientHandleValue *readData, SleHalErrorCode status)
{
    SLE_UT_LOG("[SleSsapcHalUt][PASSED]OnSleHalUtReceiveReadResponseCallback");
    return;
}

void OnSleHalUtReadByUUidCallback(uint8_t clientId, uint16_t connectId, const ClientReadByUuidCmpRes *cmpResult, SleHalErrorCode status)
{
    SLE_UT_LOG("[SleSsapcHalUt][PASSED]OnSleHalUtReadByUUidCallback");
    return;
}

void OnSleHalUtReceiveWriteResponseCallback(uint8_t clientId, uint16_t connectId, const ClientWriteRes *writeResult, SleHalErrorCode status)
{
    SLE_UT_LOG("[SleSsapcHalUt][PASSED]OnSleHalUtReceiveWriteResponseCallback");
    return;
}

void OnSleHalUtReceiveExchangeInfoResponseCallback(uint8_t clientId, uint16_t connectId, const SsapMtuInfo *param, SleHalErrorCode status)
{
    SLE_UT_LOG("[SleSsapcHalUt][PASSED]OnSleHalUtReceiveExchangeInfoResponseCallback");
    return;
}

void OnSleHalUtReceiveNotificationCallback(uint8_t clientId, uint16_t connectId, const ClientHandleValue *data, SleHalErrorCode status)
{
    SLE_UT_LOG("[SleSsapcHalUt][PASSED]OnSleHalUtReceiveNotificationCallback");
    return;
}

void OnSleHalUtReceiveIndicationCallback(uint8_t clientId, uint16_t connectId, const ClientHandleValue *data, SleHalErrorCode status)
{
    SLE_UT_LOG("[SleSsapcHalUt][PASSED]OnSleHalUtReceiveIndicationCallback");
    return;
}

void InitSleSsapcHalTestLevel0(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ret = InitSleSsapcHal();
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] InitSleSsapcHalTestLevel0 failed(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] InitSleSsapcHalTestLevel0 pass");
}

void DeinitSleSsapcHalTestLevel0(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ret = DeinitSleSsapcHal();
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] DeinitSleSsapcHalTestLevel0 failed(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] DeinitSleSsapcHalTestLevel0 pass");
}

void SleSsapcHalRegisterCallbacksTestLevel0(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ret = SleSsapcHalRegisterCallbacks(g_sleSsapcHalUtCbs);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalRegisterCallbacksTestLevel0 failed(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalRegisterCallbacksTestLevel0 pass");
}

void SleSsapcHalAddClientTestLevel0(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ret = SleSsapcHalAddClient(&g_appUuid, &g_clientId);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalAddClientTestLevel0 failed(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalAddClientTestLevel0 pass");
}

void SleSsapcHalFindStructureTestLevel0(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ClientFindStructure paramFind = {
        .findType  = SSAP_FIND_TYPE_PRIMARY_SERVICE_TYPE,
        .startHandle = 1,
        .endHandle = 0xFFFF,
        .uuid = g_appUuid,
    };
    ret = SleSsapcHalFindStructure(g_clientId, g_connectId, &paramFind);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalFindStructureTestLevel0 failed(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalFindStructureTestLevel0 pass");
}

void SleSsapcHalExchangeInfoReqTestLevel0(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    SsapMtuInfo exchangeInfo = {
        .mtuSize = 300,
    };
    ret = SleSsapcHalExchangeInfoReq(g_clientId, g_connectId, &exchangeInfo);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalExchangeInfoReqTestLevel0 failed(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalExchangeInfoReqTestLevel0 pass");
}

void SleSsapcHalWriteReqTestLevel0(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    uint8_t data[15] = {'k','h','_','s','s','a','p','c','_','t','e','s','t','0','\0'};
    ClientWriteParam writeParam = {
        .type = SLE_SSAP_PROPERTY_TYPE,
        .handle = g_propertyHandle,
        .data = data,
        .dataLength = 12,
    };
    ret = SleSsapcHalWriteReq(g_clientId, g_connectId, &writeParam);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalWriteReqTestLevel0 failed(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalWriteReqTestLevel0 pass");
}

void SleSsapcHalReadReqByUuidTestLevel0(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ClientReadReqByUUID redReqByUuid = {
        .findType  = SSAP_FIND_TYPE_PRIMARY_SERVICE_TYPE,
        .startHandle = 1,
        .endHandle = 0xFFFF,
        .uuid = g_appUuid,
    };
    ret = SleSsapcHalReadReqByUuid(g_clientId, g_connectId, &redReqByUuid);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalReadReqByUuidTestLevel0 failed(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalReadReqByUuidTestLevel0 pass");
}

void SleSsapcHalWriteCmdTestLevel0(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    uint8_t data[15] = {'k','h','_','s','s','a','p','c','_','t','e','s','t','0','\0'};
    ClientWriteParam writeParam = {
        .type = SLE_SSAP_PROPERTY_TYPE,
        .handle = g_propertyHandle,
        .data = data,
        .dataLength = 12,
    };
    ret = SleSsapcHalWriteCmd(g_clientId, g_connectId, &writeParam);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalWriteCmdTestLevel0 failed(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalRemoveClientTestLevel0 pass");
}

void SleSsapcHalReadReqTestLevel0(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ret = SleSsapcHalReadReq(g_clientId, g_connectId, g_propertyHandle, SLE_SSAP_PROPERTY_TYPE);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalReadReqTestLevel0 failed(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalRemoveClientTestLevel0 pass");
}

void SleSsapcHalRemoveClientTestLevel0(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ret = SleSsapcHalRemoveClient(g_clientId);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalRemoveClientTestLevel0 failed(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalRemoveClientTestLevel0 pass");
}

void SleSsapcHalTestLevel0(void)
{
    SLE_UT_LOG("___SleSsapcHalTestLevel0 start");
    InitSleSsapcHalTestLevel0();
    SleSsapcHalRegisterCallbacksTestLevel0();
    SleSsapcHalAddClientTestLevel0();
    SleSsapcHalFindStructureTestLevel0();
    sleep(1);
    SleSsapcHalExchangeInfoReqTestLevel0();
    sleep(1);
    SleSsapcHalWriteReqTestLevel0();
    SleSsapcHalReadReqByUuidTestLevel0();
    SleSsapcHalWriteCmdTestLevel0();
    SleSsapcHalReadReqTestLevel0();
    SleSsapcHalRemoveClientTestLevel0();
    DeinitSleSsapcHalTestLevel0();
    SLE_UT_LOG("___SleSsapcHalTestLevel0 end");
}

void InitSleSsapcHalTestLevel1(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ret = InitSleSsapcHal();
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] InitSleSsapcHalTestLevel1 failed1(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] InitSleSsapcHalTestLevel1 pass1");
    //测试重复调用
    ret = InitSleSsapcHal();
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] InitSleSsapcHalTestLevel1 failed2(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] InitSleSsapcHalTestLevel1 pass2");
}

void DeinitSleSsapcHalTestLevel1(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ret = DeinitSleSsapcHal();
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] DeinitSleSsapcHalTestLevel1 failed1(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] DeinitSleSsapcHalTestLevel1 pass1");
    //测试重复调用
    ret = DeinitSleSsapcHal();
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] DeinitSleSsapcHalTestLevel1 failed2(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] DeinitSleSsapcHalTestLevel1 pass2");
}

void SleSsapcHalRegisterCallbacksTestLevel1(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    //测试入参为NULL
    ret = SleSsapcHalRegisterCallbacks(NULL);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_ERR_INVALID_PARAM, "[SleSsapcHalTest][FAILED] SleSsapcHalRegisterCallbacksTestLevel1 failed1(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalRegisterCallbacksTestLevel1 pass1");
    
    ret = SleSsapcHalRegisterCallbacks(g_sleSsapcHalUtCbs);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalRegisterCallbacksTestLevel1 failed2(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalRegisterCallbacksTestLevel1 pass2");
}

void SleSsapcHalAddClientTestLevel1(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    //测试入参为NULL
    ret = SleSsapcHalAddClient(&g_appUuid, NULL);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_ERR_INVALID_PARAM, "[SleSsapcHalTest][FAILED] SleSsapcHalAddClientTestLevel1 failed1(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalAddClientTestLevel1 pass1");
    ret = SleSsapcHalAddClient(NULL, &g_clientId);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_ERR_INVALID_PARAM, "[SleSsapcHalTest][FAILED] SleSsapcHalAddClientTestLevel1 failed2(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalAddClientTestLevel1 pass2");

    ret = SleSsapcHalAddClient(&g_appUuid, &g_clientId);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalAddClientTestLevel1 failed3");
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalAddClientTestLevel1 pass3");
}

void SleSsapcHalFindStructureTestLevel1(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    //测试入参为NULL
    ClientFindStructure paramFind = {
        .findType  = SSAP_FIND_TYPE_PRIMARY_SERVICE_TYPE,
        .startHandle = 1,
        .endHandle = 0xFFFF,
        .uuid = g_appUuid,
    };
    ret = SleSsapcHalFindStructure(g_clientId, g_connectId, NULL);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_ERR_INVALID_PARAM, "[SleSsapcHalTest][FAILED] SleSsapcHalFindStructureTestLevel1 failed1(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalFindStructureTestLevel1 pass1");

    ret = SleSsapcHalFindStructure(g_clientId, g_connectId, &paramFind);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalFindStructureTestLevel1 failed2(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalFindStructureTestLevel1 pass2");
}

void SleSsapcHalExchangeInfoReqTestLevel1(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    SsapMtuInfo exchangeInfo = {
        .mtuSize = 300,
    };
    //测试入参为NULL
    ret = SleSsapcHalExchangeInfoReq(g_clientId, g_connectId, NULL);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_ERR_INVALID_PARAM, "[SleSsapcHalTest][FAILED] SleSsapcHalExchangeInfoReqTestLevel1 failed1(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalExchangeInfoReqTestLevel1 pass1");

    ret = SleSsapcHalExchangeInfoReq(g_clientId, g_connectId, &exchangeInfo);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalExchangeInfoReqTestLevel1 failed2(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalExchangeInfoReqTestLevel1 pass2");
}

void SleSsapcHalWriteReqTestLevel1(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    uint8_t data[15] = {'k','h','_','s','s','a','p','c','_','t','e','s','t','0','\0'};
    ClientWriteParam writeParam = {
        .type = SLE_SSAP_PROPERTY_TYPE,
        .handle = g_propertyHandle,
        .data = data,
        .dataLength = 2,
    };
    //测试入参为NULL
    ret = SleSsapcHalWriteReq(g_clientId, g_connectId, NULL);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_ERR_INVALID_PARAM, "[SleSsapcHalTest][FAILED] SleSsapcHalWriteReqTestLevel1 failed1(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalWriteReqTestLevel1 pass1");

    ret = SleSsapcHalWriteReq(g_clientId, g_connectId, &writeParam);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalWriteReqTestLevel1 failed2(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalWriteReqTestLevel1 pass2");
}

void SleSsapcHalReadReqByUuidTestLevel1(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ClientReadReqByUUID redReqByUuid = {
        .findType  = SSAP_FIND_TYPE_PRIMARY_SERVICE_TYPE,
        .startHandle = 1,
        .endHandle = 0xFFFF,
        .uuid = g_appUuid,
    };
    //测试入参为NULL
    ret = SleSsapcHalReadReqByUuid(g_clientId, g_connectId, NULL);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_ERR_INVALID_PARAM, "[SleSsapcHalTest][FAILED] SleSsapcHalReadReqByUuidTestLevel1 failed1(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalReadReqByUuidTestLevel1 pass1");

    ret = SleSsapcHalReadReqByUuid(g_clientId, g_connectId, &redReqByUuid);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalReadReqByUuidTestLevel1 failed2(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalReadReqByUuidTestLevel1 pass2");
}

void SleSsapcHalWriteCmdTestLevel1(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    uint8_t data[10] = {1};
    ClientWriteParam writeParam = {
        .type = SLE_SSAP_PROPERTY_TYPE,
        .handle = g_propertyHandle,
        .data = data,
        .dataLength = 2,
    };
    //测试入参为NULL
    ret = SleSsapcHalWriteCmd(g_clientId, g_connectId, NULL);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_ERR_INVALID_PARAM, "[SleSsapcHalTest][FAILED] SleSsapcHalWriteCmdTestLevel1 failed1(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalWriteCmdTestLevel1 pass1");

    ret = SleSsapcHalWriteCmd(g_clientId, g_connectId, &writeParam);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalWriteCmdTestLevel1 failed2(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalWriteCmdTestLevel1 pass2");
}

void SleSsapcHalReadReqTestLevel1(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ret = SleSsapcHalReadReq(g_clientId, g_connectId, g_propertyHandle, SLE_SSAP_PROPERTY_TYPE);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalReadReqTestLevel1 failed2(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalReadReqTestLevel1 pass");
}

void SleSsapcHalRemoveClientTestLevel1(void)
{
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ret = SleSsapcHalRemoveClient(g_clientId);
    SLE_UT_CHECK_AND_PRINT_LOG(ret == SLE_HAL_SUCCESS, "[SleSsapcHalTest][FAILED] SleSsapcHalRemoveClientTestLevel1 failed(%d)", ret);
    SLE_UT_LOG("[SleSsapcHalTest][PASSED] SleSsapcHalRemoveClientTestLevel1 pass");
}

void SleSsapcHalTestLevel1(void)
{
    SLE_UT_LOG("___SleSsapcHalTestLevel1 start");
    InitSleSsapcHalTestLevel1();
    SleSsapcHalRegisterCallbacksTestLevel1();
    SleSsapcHalAddClientTestLevel1();
    SleSsapcHalFindStructureTestLevel1();
    sleep(1);
    SleSsapcHalExchangeInfoReqTestLevel1();
    sleep(1);
    SleSsapcHalWriteReqTestLevel1();
    SleSsapcHalReadReqByUuidTestLevel1();
    SleSsapcHalWriteCmdTestLevel1();
    SleSsapcHalReadReqTestLevel1();
    SleSsapcHalRemoveClientTestLevel1();
    DeinitSleSsapcHalTestLevel1();
    SLE_UT_LOG("___SleSsapcHalTestLevel1 end");
}

SleHalErrorCode InitSleSsapcHalTestEntry(void)
{
    g_sleSsapcHalUtCbs = (SleSsapcHalCallbacks *)malloc(sizeof(SleSsapcHalCallbacks));
    SLE_UT_CHECK_AND_RETURN_RET_LOG(g_sleSsapcHalUtCbs != NULL, SLE_HAL_ERR_DRIVER_OR_SYSTEM,"[SleSsapcHalTest][FAILED] malloc g_sleSsapcHalUtCbs failed");
    g_sleSsapcHalUtCbs->OnSsapcStructFoundCb = OnSleHalUtFindStructureCallback;
    g_sleSsapcHalUtCbs->OnSsapcPropertyFoundCb = OnSleHalUtFindPropertyCallback;
    g_sleSsapcHalUtCbs->OnSsapcFindStructDoneCb = OnSleHalUtCompleteFindStructureCallback;
    g_sleSsapcHalUtCbs->OnSsapcRecvReadRespCb = OnSleHalUtReceiveReadResponseCallback;
    g_sleSsapcHalUtCbs->OnSsapcReadByUuidCb = OnSleHalUtReadByUUidCallback;
    g_sleSsapcHalUtCbs->OnSsapcRecvWriteRespCb = OnSleHalUtReceiveWriteResponseCallback;
    g_sleSsapcHalUtCbs->OnSsapcRecvExchangeInfoRespCb = OnSleHalUtReceiveExchangeInfoResponseCallback;
    g_sleSsapcHalUtCbs->OnSsapcRecvNotificationCb = OnSleHalUtReceiveNotificationCallback;
    g_sleSsapcHalUtCbs->OnSsapcRecvIndicationCb = OnSleHalUtReceiveIndicationCallback;
    uint8_t uuid[UUID_LEN] = {1};
    memcpy(g_appUuid.uuid, uuid, UUID_LEN);
    return SLE_HAL_SUCCESS;
}

SleHalErrorCode DeinitSleSsapcHalTestEntry(void)
{
    if (g_sleSsapcHalUtCbs != NULL) {
        free(g_sleSsapcHalUtCbs);
        g_sleSsapcHalUtCbs = NULL;
    }
    return SLE_HAL_SUCCESS;
}

void SleSsapcHalTestEntry(void)
{
    SLE_UT_LOG("__SleSsapcHalTestEntry start");
    SleHalErrorCode ret = SLE_HAL_ERR_UNKNOWN;
    ret = InitSleSsapcHalTestEntry();
    SLE_UT_CHECK_AND_RETURN(ret == SLE_HAL_SUCCESS);
    SleSsapcHalTestLevel0();
    SleSsapcHalTestLevel1();
    ret = DeinitSleSsapcHalTestEntry();
    SLE_UT_CHECK_AND_RETURN(ret == SLE_HAL_SUCCESS);
    SLE_UT_LOG("__SleSsapcHalTestEntry end");
}